#!/bin/bash
#########################################################################
# Author      : zkk@crscd.com.cn
# Created Time: Thu 26 Mar 2015 05:34:22 AM PDT
# File Name   : mkramdisk_p2.sh
# Description : 
#########################################################################
echo ""
echo "Script to generate initial ramdisk for embedde linux -- Part 2"
echo "Make sure the file of 'ramdisk.gz' and the subdirectory of 'new'&'old' existing here"
echo ""
#umount new
echo "umount ./new"
umount ./new
echo ""

#make new ramdisk
if [ -f /tmp/ramdisk.img.gz ] ; then
	echo "rm -f /tmp/ramdisk.img.gz"
	rm -f /tmp/ramdisk.img.gz
	echo "" 
fi
echo "gzip -9 /tmp/ramdisk.img"
gzip -9 /tmp/ramdisk.img
echo ""
if [ -f ./ramdisk.gz ] ; then
	echo "cp -f ./ramdisk.gz ./ramdisk.gz.bak"
	cp -f ./ramdisk.gz ./ramdisk.gz.bak
	echo ""
fi
echo "cp /tmp/ramdisk.img.gz ./ramdisk.gz"
cp /tmp/ramdisk.img.gz ./ramdisk.gz
echo ""
if [ -f ./uRamdisk ] ; then
	echo "rm -f ./uRamdisk"
	rm -f ./uRamdisk
	echo ""
fi
#echo "mkimage -A ppc -O linux -T ramdisk -C gzip -a 0 -e 0 -n 'init ramdisk' -d ramdisk.gz uRamdisk"
#mkimage -A ppc -O linux -T ramdisk -C gzip -a 0 -e 0 -n 'init ramdisk' -d ramdisk.gz uRamdisk
echo "mkimage -A arm -O linux -T ramdisk -C gzip -a 0 -e 0 -n 'init ramdisk' -d ramdisk.gz uRamdisk"
mkimage -A arm -O linux -T ramdisk -C gzip -a 0 -e 0 -n 'init ramdisk' -d ramdisk.gz uRamdisk
echo ""
